package br.com.fafica.sisape.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;

import br.com.fafica.sisape.control.ControllerPrincipal;

public class TelaPrincipal extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TelaPrincipal frame = new TelaPrincipal();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TelaPrincipal() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1000, 600);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnVizualizarUsurio = new JButton(" Usu\u00E1rios");
		btnVizualizarUsurio.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastroUsuario telaCadastrarUsuario = new TelaCadastroUsuario();
				telaCadastrarUsuario.setLocationRelativeTo(null); 
				telaCadastrarUsuario.setVisible(true);
			}
		});
		btnVizualizarUsurio.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnVizualizarUsurio.setBounds(794, 253, 175, 36);
		contentPane.add(btnVizualizarUsurio);
		
		JButton btnCadastrarMdico = new JButton("M\u00E9dico");
		btnCadastrarMdico.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastroMedico telaCadastrarMedico = new TelaCadastroMedico();
				telaCadastrarMedico.setLocationRelativeTo(null);
				telaCadastrarMedico.setVisible(true);
			}
		});
		btnCadastrarMdico.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnCadastrarMdico.setBounds(22, 253, 175, 36);
		contentPane.add(btnCadastrarMdico);
		
		JButton btnConsulta = new JButton("Consultas M\u00E9dicas");
		btnConsulta.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastrarConsultas telaCadastroConsul = new TelaCadastrarConsultas();
				telaCadastroConsul.setLocationRelativeTo(null);
				telaCadastroConsul.setVisible(true);
			}
		});
		btnConsulta.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnConsulta.setBounds(22, 300, 175, 36);
		contentPane.add(btnConsulta);
		
		JButton btnExames = new JButton("Exames");
		btnExames.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastrarExames telaCadastroExa = new TelaCadastrarExames();
				telaCadastroExa.setLocationRelativeTo(null);
				telaCadastroExa.setVisible(true);
			}
		});
		btnExames.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnExames.setBounds(22, 347, 175, 36);
		contentPane.add(btnExames);
		
		JButton btnInternaes = new JButton("Interna\u00E7\u00F5es");
		btnInternaes.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastrarInternacoes telaCadastroInter = new TelaCadastrarInternacoes();
				telaCadastroInter.setLocationRelativeTo(null);
				telaCadastroInter.setVisible(true);
			}
		});
		btnInternaes.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnInternaes.setBounds(22, 394, 175, 36);
		contentPane.add(btnInternaes);
		
		JButton btnTratamentos = new JButton("Tratamentos");
		btnTratamentos.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastrarTratamentos telaCadastroTrata = new TelaCadastrarTratamentos();
				telaCadastroTrata.setLocationRelativeTo(null);
				telaCadastroTrata.setVisible(true);
			}
		});
		btnTratamentos.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnTratamentos.setBounds(22, 441, 175, 36);
		contentPane.add(btnTratamentos);
		
		JButton btnAlergias = new JButton("Alergias");
		btnAlergias.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaCadastrarAlergias telaCadastroAler = new TelaCadastrarAlergias();
				telaCadastroAler.setLocationRelativeTo(null);
				telaCadastroAler.setVisible(true);
			}
		});
		btnAlergias.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnAlergias.setBounds(22, 488, 175, 36);
		contentPane.add(btnAlergias);
		
		JButton btnConsultaDeMedicamentos = new JButton("Consulta de Medicamentos");
		btnConsultaDeMedicamentos.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnConsultaDeMedicamentos.setBounds(511, 253, 260, 36);
		contentPane.add(btnConsultaDeMedicamentos);
		
		JButton btnHistricoCompleto = new JButton("Hist\u00F3rico Completo");
		btnHistricoCompleto.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaVizualizarUsuarios telaUsuario = new TelaVizualizarUsuarios();
				telaUsuario.setLocationRelativeTo(null);
				telaUsuario.setVisible(true);
			}
		});
		btnHistricoCompleto.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnHistricoCompleto.setBounds(220, 253, 260, 36);
		contentPane.add(btnHistricoCompleto);
		
		JButton btnHistricoExames = new JButton("Hist\u00F3rico - Exames");
		btnHistricoExames.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnHistricoExames.setBounds(220, 300, 260, 36);
		contentPane.add(btnHistricoExames);
		
		JButton btnHistricoInternaes = new JButton("Hist\u00F3rico - Interna\u00E7\u00F5es");
		btnHistricoInternaes.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnHistricoInternaes.setBounds(220, 347, 260, 36);
		contentPane.add(btnHistricoInternaes);
		
		JButton btnHistricoTratamentos = new JButton("Hist\u00F3rico - Tratamentos");
		btnHistricoTratamentos.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnHistricoTratamentos.setBounds(220, 394, 260, 36);
		contentPane.add(btnHistricoTratamentos);
		
		JButton btnHistricoConsultas = new JButton("Hist\u00F3rico - Consultas M\u00E9dicas");
		btnHistricoConsultas.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnHistricoConsultas.setBounds(220, 441, 260, 36);
		contentPane.add(btnHistricoConsultas);
		
		JLabel lblCadastros = new JLabel("Cadastros & Altera\u00E7\u00F5es");
		lblCadastros.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblCadastros.setBounds(22, 221, 150, 21);
		contentPane.add(lblCadastros);
		
		JLabel lblRelatrios = new JLabel("Relat\u00F3rios:");
		lblRelatrios.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblRelatrios.setBounds(220, 221, 72, 21);
		contentPane.add(lblRelatrios);
		
		JLabel lblMedicamentos = new JLabel("Medicamentos:");
		lblMedicamentos.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblMedicamentos.setBounds(511, 221, 105, 21);
		contentPane.add(lblMedicamentos);
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.BLACK);
		panel.setBounds(207, 221, 3, 256);
		contentPane.add(panel);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBackground(Color.BLACK);
		panel_1.setBounds(10, 221, 3, 303);
		contentPane.add(panel_1);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBackground(Color.BLACK);
		panel_2.setBounds(493, 221, 3, 68);
		contentPane.add(panel_2);
		
		JButton btnSair = new JButton("SAIR");
		btnSair.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		btnSair.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnSair.setBounds(794, 300, 175, 36);
		contentPane.add(btnSair);
		
		JPanel panel_3 = new JPanel();
		panel_3.setBackground(Color.BLACK);
		panel_3.setBounds(781, 221, 3, 162);
		contentPane.add(panel_3);
		
		JLabel lblUsurios = new JLabel("Usu\u00E1rios:");
		lblUsurios.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblUsurios.setBounds(799, 221, 105, 21);
		contentPane.add(lblUsurios);
		
		JLabel lblUsurio = new JLabel("Usu\u00E1rio:");
		lblUsurio.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUsurio.setFont(new Font("Times New Roman", Font.PLAIN, 16));
		lblUsurio.setBounds(10, 124, 60, 21);
		contentPane.add(lblUsurio);
		
		JLabel lblUsuario = new JLabel("");
		lblUsuario.setFont(new Font("Times New Roman", Font.PLAIN, 16));
		lblUsuario.setBounds(80, 124, 175, 21);
		contentPane.add(lblUsuario);
		String user = "";
		try{
			ControllerPrincipal controlUserLogado = new ControllerPrincipal();
			user = controlUserLogado.usuarioLogado();
			lblUsuario.setText(user);
		}catch(NullPointerException e){
			System.out.println(e.getMessage());
		}
		
		
		JLabel label = new JLabel("");
		label.setForeground(Color.BLACK);
		label.setIcon(new ImageIcon("arquivos\\FundoTelaPrincipal.png"));
		label.setBounds(0, 0, 994, 571);
		contentPane.add(label);
	}
}
